/*
 * Copyright (c) 2006, 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * <p>Project: jse2204 - Reg7
 * <p>Powered by webrx On 2022-09-14 16:42:42
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Reg7 {

    public static void main(String[] args) {
        //Pattern p = Pattern.compile("[a-zA-Z]{3}");
        Pattern p = Pattern.compile("[a-z]{3}");
        Matcher m = p.matcher("Abc");
        System.out.println(m.find());
        System.out.println(m.matches());

        //Pattern.CASE_INSENSITIVE 不区分大小写参数
        p = Pattern.compile("[A-Z]{3}", Pattern.CASE_INSENSITIVE);
        m = p.matcher("Abc");
        System.out.println(m.find());
        System.out.println(m.matches());
    }


    public static void ok(String[] args) {
        String str = "Hello world,hello java";
        System.out.println("===========区分大小写===========");
        Pattern p = Pattern.compile("hello");
        Matcher m = p.matcher(str);
        while (m.find()) {
            System.out.println(m.group() + "   位置：[" + m.start() + "," + m.end() + "]");
        }

        System.out.println("===========不区分大小写===========");
        p = Pattern.compile("hello", Pattern.CASE_INSENSITIVE);
        m = p.matcher(str);
        while (m.find()) {
            System.out.println(m.group() + "   位置：[" + m.start() + "," + m.end() + "]");
        }
    }

    public static void test(String[] args) {
        Pattern p = Pattern.compile("[a-z]+");
        System.out.println(p);
        System.out.println(p.toString());

        String pp = "[a-z]+";
        System.out.println(pp);

        Matcher m1 = p.matcher("Abc");
        System.out.println(m1.matches());
        System.out.println(m1.find());
        System.out.println("-------------");
        Pattern p2 = Pattern.compile("[a-z]", Pattern.CASE_INSENSITIVE);
        System.out.println(p2);

        Matcher m2 = p2.matcher("Abc");
        System.out.println(m2.find());

    }
}
